{extend name="layout/detail" /}

{block name="content"}
<div class="td-content-wrap p20">
    <div class="td-content-header">
        <h1 class="main-title">系统数据</h1>
    </div>
    <hr>
    <div class="layui-form panel">
        <a class="layui-btn" onclick="add();">添加</a>
    </div>
    <table class="layui-table column" lay-skin="line" id="layui_table">
        <thead>
        <tr>
            <th>序号</th>
            <th>编码</th>
            <th>名称</th>
            <th>简介</th>
            <th>排序</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        {volist name="vo_list" id="menu" empty="
        <tr class='data-empty'>
            <td colspan='6'>无数据</td>
        </tr>
        "}
        <tr>
            <td>{$menu.id}</td>
            <td>{$menu.code}</td>
            <td>{$menu.name}</td>
            <td>{$menu.desc}</td>
            <td>{$menu.sort}</td>
            <td>
                <a class="layui-btn layui-btn-xs" onclick="edit_data({$menu.id})">编辑数据</a>
                <a class="layui-btn layui-btn-xs" onclick="edit({$menu.id})">编辑</a>
                <a class="layui-btn layui-btn-danger layui-btn-xs" onclick="del({$menu['id']})">删除</a>
                <a class="layui-btn layui-btn-xs" onclick="sort_up({$menu.id})"><i class="fa fa-arrow-up"></i></a>
                <a class="layui-btn layui-btn-xs" onclick="sort_down({$menu.id})"><i class="fa fa-arrow-down"></i></a>
            </td>
        </tr>
        {/volist}
        </tbody>
    </table>
</div>
{/block}

{block name="script"}
<script>
    layui.use(['form', 'element'], function () {
        let $ = layui.jquery;
        set_return_url(null);

        var fn = {
            index: function (module) {
                window.open('{:url("index")}', '_self');
            },
            add: function () {
                window.open('{:url("add")}', '_self');
            },
            edit: function (id) {
                window.open("{:url('edit')}?id=" + id, '_self');
            },
            edit_data: function (id) {
                window.open("{:url('system_group_data/index')}?group_id=" + id, '_self');
            },
            del: function (id) {
                layer.msg('确定要删除吗?', {
                    time: 0,
                    btn: ['确定', '取消'],
                    yes: function (index) {
                        var vars = 'id=' + id;
                        $.get("{:url('del')}", vars, function (ret) {
                            if (ret.code) {
                                layer.msg(ret.msg, {
                                    time: 1200
                                }, function () {
                                    location.reload(true);
                                });
                            } else {
                                layer.msg(ret.msg, {
                                    time: 1200
                                });
                            }
                        });
                    },
                    no: function (index) {
                        layer.close(index);
                    }
                });
            },
            sort_up: function (id) {
                var vars = "id=" + id;
                $.get("{:url('sort_up')}", vars, function (data) {
                    if (data.code) {
                        layer.msg(data.msg, {
                            time: 1200
                        }, function () {
                            location.reload(true);
                        });
                    } else {
                        layer.msg(data.msg);
                    }
                });
            },
            sort_down: function (id) {
                var vars = "id=" + id;
                $.get("{:url('sort_down')}", vars, function (data) {
                    if (data.code) {
                        layer.msg(data.msg, {
                            time: 1200
                        }, function () {
                            location.reload(true);
                        });
                    } else {
                        layer.msg(data.msg);
                    }
                });
            }
        };
        win_exp(fn);

        var form = layui.form;
        form.on('select(test)', function (data) {
            $('#form_search').submit();
        });
    });
</script>
{/block}